var app = getApp();
var Const = require('./../../../utils/const');

Page({
	data: {

	},

	onLoad: function (e) {

	},

	getUserInfo: function (e) {
		wx.getSetting({
			success(res) {
				if (!res.authSetting['scope.userInfo']) {
					wx.authorize({
						scope: 'scope.userInfo',
						success() {
							wx.setStorageSync(Const.DATA.KEY_AUTH, true);
							wx.redirectTo({
								url: '/pages/user/login/login?type=' + Const.TOPTIPS.WARN + '&msg=' + Const.ERROR_MSG.NOT_LOGIN
							})
						},
						fail() {
							wx.setStorageSync(Const.DATA.KEY_AUTH, false);
						}
					})
				} else {
					wx.setStorageSync(Const.DATA.KEY_AUTH, true);
					wx.redirectTo({
						url: '/pages/user/login/login?type=' + Const.TOPTIPS.WARN + '&msg=' + Const.ERROR_MSG.NOT_LOGIN
					})
				}
			}
		});
	}
});
